<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理后台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<{$domain}>themes/admin_login.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="Container">
	<div id="Body" class="clearfix">
		<div id="Sidebar">管理后台</div>
		<div id="Main">
			<form id="loginForm" method="post">
			<table cellspacing="0" cellpadding="0">
			  <tr>
				<td class="label">用户名：</td>
				<td><input type="text" class="text required" id="username" name="username" title="用户名不能为空" /></td>
			  </tr>
			  <tr>
				<td class="label">密　码：</td>
				<td><input type="password" class="text required" id="password" name="password" title="密码不能为空" /></td>
			  </tr>
			  <tr>
				<td class="label">验证码：</td>
				<td><input type="text" class="text required" id="captcha" name="captcha" title="验证码不能为空" /></td>
			  </tr>
			  <tr>
				<td></td>
				<td><img src="<{url r='admin/site/captcha'}>" align="top" id="captchaImg" /></td>
			  </tr>
			  <tr>
			  	<td></td>
				<td>
					<input type="submit" class="button" id="btnSubmit" value="登 录" />
					<div id="loading" class="tip"><img src="<{$domain}>images/admin/loading2.gif" align="absmiddle" />&nbsp;登录系统中 ...</div>
					<div id="logResult" class="tip"></div>
				</td>
			  </tr>
			</table>
			</form>
		</div>
	</div>
	<div id="Footer"><div>版权所有 © 2009-2012 www.e35go.com，并保留所有权利。</div></div>
</div>
</body>
</html>

<!-- 脚本 -->
<script type="text/javascript" src="<{$domain}>javascript/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="<{$domain}>javascript/jquery.validate.js"></script>
<script type="text/javascript" src="<{$domain}>javascript/jquery.form.js"></script>
<script type="text/javascript">
///
function captchaRefresh() {
	$("#captchaImg").attr("src", "<{url r='admin/site/captcha'}>?" + Math.random());
}

///
$(function($) {
	$("#loginForm").validate({
		submitHandler: function() {
			$("#loading").css("display", "inline");
			$("#logResult").hide().html("");
			
			///
			$("#loginForm").ajaxSubmit({
				type: "POST", url: "<{url r=$smarty.get.url}>", data: {},
				success: function(data) {
					$("#loading").hide();
					
					///
					var message = "";
					var element = $("#username");
					switch(data) {
						case "1":
							message = "验证码输入有误";
							break;
						case "2":
							message = "帐号或密码有误";
							break;
						default:
							message = "系统错误";
							break;
					}
					if (data != "0") {
						$("#logResult").css("display", "inline-block").html(message);
					} else {
						window.location.href = "<{url r='admin/main'}>";
					}
				}
			});
			
			return false;
		}
	});
	
	$("#captchaImg")
		.css("cursor", "pointer")
		.attr("title", "看不清？点击更换另一个验证码。")
		.click(function() {
			captchaRefresh();
		});
});
</script>
